/* 
平台属性相关接口的请求函数
*/
import request from '@/utils/request'
import type { AttrListModel, AttrModel, CategoryIdsModel } from './model/AttrModel';

enum Api {
  // GET /admin/product/attrInfoList/{category1Id}/{category2Id}/{category3Id}
  GetAttrList = '/admin/product/attrInfoList',
  // POST /admin/product/saveAttrInfo
  SaveAttr = '/admin/product/saveAttrInfo',
  // DELETE /admin/product/deleteAttr/{attrId}
  DeleteAttr = '/admin/product/deleteAttr',
}

// 获取属性列表
export const getAttrListApi = (params: CategoryIdsModel) => {
  return request.get<any, AttrListModel>(Api.GetAttrList + `/${params.category1Id}/${params.category2Id}/${params.category3Id}`)
}
// 添加和更新属性
export const saveAttrApi = (attr: AttrModel) => {
  return request.post(Api.SaveAttr, attr)
}
// 删除属性
export const deleteAttrApi = (id: number) => {
  return request.delete(Api.DeleteAttr + `/${id}`)
}